package cz.muni.fi.pa165.bookingmanager.adapters;

import cz.muni.fi.pa165.bookingmanager.dto.HotelDTO;
import cz.muni.fi.pa165.bookingmanager.dto.RoomDTO;
import cz.muni.fi.pa165.bookingmanager.exceptions.IllegalOrphanException;
import cz.muni.fi.pa165.bookingmanager.exceptions.NonexistentEntityException;
import cz.muni.fi.pa165.bookingmanager.exceptions.PreexistingEntityException;
import java.math.BigDecimal;
import java.util.List;
import javax.ejb.Local;

/**
 *
 * @author Jiří Holuša
 */
@Local
public interface RoomAdapter {
    
    /**
     * Creates new Room in database and sets its ID
     * 
     * @param room Room object to be created
     * @throws IllegalArgumentException when room == null
     * @throws IllegalOrphanException when room id is already set
     * @throws PreexistingEntityException when room with selected ID already exists
     */
    public void createRoom(RoomDTO room) throws IllegalOrphanException, PreexistingEntityException;
    
    /**
     * Updates existing Room in database
     * 
     * @param room Room object to be updated
     * @throws IllegalArgumentException when room == null or some of the not-optional arguments of Room is missing
     * @throws IllegalOrphanException when room id == null
     * @throws NonexistentEntityException when Room with set id doesn't exist in database
     */
    public void updateRoom(RoomDTO room) throws IllegalOrphanException, NonexistentEntityException;
    
    /**
     * Deletes room from database
     * 
     * @param room 
     * @throws IllegalArgumentException when room == null
     * @throws IllegalOrphanException when room id == null
     * @throws NonexistentEntityException when Room with set id doesn't exist in database
     */
    public void deleteRoom(RoomDTO room) throws IllegalOrphanException, NonexistentEntityException;;
    
    /**
     * Retrieves Room by ID
     * 
     * @param id id of the room to be retrived
     * @return Room object with set ID or null when room object doesn't exist
     */
    public RoomDTO getRoomById(Long id);    
    
    /**
     * Retrieves rooms identified by its number in selected hotel
     * 
     * @param number number of the room
     * @param hotel hotel
     * @return desired Room object or null when room doesn't exist
     */
    public RoomDTO findRoomByNumber(String number, HotelDTO hotel);
   
    /** 
     * Retrieves all room in selected hotel
     * 
     * @param hotel hotel
     * @return list of rooms in the selected hotel
     */
    public List<RoomDTO> findAllHotelRooms(HotelDTO hotel);
    
    /**
     * Finds all rooms (everywhere) with price between 'from' and 'to'
     * 
     * @param from lower boundary of the selection
     * @param to higher boundary of the selection
     * @return list of rooms selected by the criteria
     */
    public List<RoomDTO> findRoomsByPrice(BigDecimal from, BigDecimal to);
    
    /**
     * Finds all rooms (in desired hotel) with price between 'from' and 'to'
     * 
     * @param from lower boundary of the selection
     * @param to higher boundary of the selection
     * @param hotel hotel where we want to search
     * @return list of rooms selected by the criteria
     */
    public List<RoomDTO> findRoomsByPrice(BigDecimal from, BigDecimal to, HotelDTO hotel);
    
    /**
     * Finds all rooms (everywhere) with selected capacity 
     * 
     * @param capacity capacity of the room
     * @return list of rooms selected by the criteria
     */
    public List<RoomDTO> findRoomsByCapacity(int capacity);
    
    /**
     * Finds all rooms (in selected hotel) with selected capacity 
     * 
     * @param capacity capacity of the room
     * @param hotel hotel where we want to search
     * @return list of rooms selected by the criteria
     */
    public List<RoomDTO> findRoomsByCapacity(int capacity, HotelDTO hotel);

}
